{template 'common/header'}
<ul class="nav nav-tabs">
     {if $user}<li {if $operation=='set' }class="active" {/if}><a href="{php echo $this->createWebUrl('business', array('op' => 'dp','operation' => 'set'))}">个人设置</a></li>{/if}
    <li {if $operation=='list' }class="active" {/if}><a href="{php echo $this->createWebUrl('business', array('op' => 'dp','operation' => 'list'))}">店铺列表</a></li>
    <li {if $operation=='add' }class="active" {/if}><a href="{php echo $this->createWebUrl('business', array('op' => 'dp','operation' => 'add'))}">添加店铺</a></li>
</ul>
<form action="" class="form-horizontal" method="post" enctype="multipart/form-data" onsubmit="return check(this);">
    <input type="hidden" name="id" value="{$item['id']}">
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="form-group">
                <label for="sjname" class="col-sm-2 control-label">商家名称</label>
                <div class="col-sm-4">
                    <input type="text" name="sjname" id='sjname' value="{$item['sjname']}" class="form-control" placeHolder="请输入商家名称" />
                </div>
            </div>
            <div class="form-group">
                <label for="contactname" class="col-sm-2 control-label">联系人</label>
                <div class="col-sm-4">
                    <input type="text" name="contactname" id='contactname' value="{$item['contactname']}" class="form-control" placeHolder="请输入商家联系人" />
                </div>
            </div>
            <div class="form-group" id='s1'>
                <label for="mobile" class="col-sm-2 control-label">手机</label>
                <div class="col-sm-4">
                    <input type="text" name="mobile" id='mobile' value="{$item['mobile']}" class="form-control" placeHolder="请输入商家联系人手机" />
                </div>
            </div>
            <div class="form-group" id='s2'>
                <label for="phone" class="col-sm-2 control-label">电话</label>
                <div class="col-sm-4">
                    <input type="text" name="phone" id='phone' value="{$item['phone']}" class="form-control" placeHolder="请输入商家电话" />
                </div>
            </div>
            <div class="form-group">
                <label for="qq" class="col-sm-2 control-label">QQ号</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" placeholder="请输入商家QQ号" name="qq" value="{$item['qq']}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="text-danger">*</span> 营业时间</label>
                <div class="col-sm-9 col-xs-4 col-md-3">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="8:00" name="open_time_start" value="{$businesstime[0]}">
                        <span class="input-group-addon" id="basic-addon2">-</span>
                        <input type="text" class="form-control" placeholder="24:00" name="open_time_end" value="{$businesstime[1]}">
                    </div>
                    <span class="help-block">营业时间，24小时制表示，如 8:00-20:00</span>
                </div>
            </div>
            <div class="form-group" id='s4'>
                <label for="" class="col-sm-2 control-label">展示图片</label>
                <div class="col-sm-6">
                    {php echo tpl_form_field_image(picurl,$item['picurl']);}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">行业</label>
                {php echo tpl_form_field_industry('industry', $item['parent'], $item['child'])}
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="text-danger">*</span> 地址</label>
                <div class="col-sm-8 col-xs-12">
                    {php echo tpl_form_field_district('reside',array('province' => $item['province'],'city' => $item['city'],'district' => $item['dist']));}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="text-danger">*</span> 详细地址</label>
                <div class="col-sm-8 col-xs-12">
                    <input type="text" name="address" id="addresss" class="form-control" placeholder="输入详细地址，请勿重复填写省市区信息" value="{$item['address']}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="text-danger">*</span> 定位</label>
                <div class="col-sm-8 col-xs-12" id="map">
                    {php echo tpl_form_field_coordinate('baidumap', array('lng' => $item['lng'],'lat' => $item['lat']))}
                </div>
            </div>
            <div class="form-group">
                <label for="qq" class="col-sm-2 control-label">商家外链</label>
                <div class="col-sm-6">
                    {php echo tpl_form_field_link('businessurl',$item['businessurl'])}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="text-danger"></span> 简介</label>
                <div class="col-sm-8 col-xs-12">
                    <textarea name="shopdesc" class="form-control" cols="30" rows="5" id='shopdesc'>{$item['shopdesc']}</textarea>
                    <span class="help-block">商户简介，主要介绍商户信息等 </span>
                </div>
            </div>
           <!--  {if !$user}
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">选择小区</label>
                <div class="col-sm-10">
                    <label class="checkbox-inline">
                        <input type="checkbox" id="checkAll" name="checkAll" data-group="regionid">全部
                    </label>
                    {loop $regions $region}
                    <label class="checkbox-inline">
                        <input type="checkbox" id="regionid" value="{$region['id']}" name='regionid[]' data-group="regionid" {if @in_array($region[ 'id'], $regs)}checked='checked' {/if}> {$region['title']}
                    </label>
                    {/loop}
                </div>
            </div>
            {/if} -->
            <div class="form-group">
                <label for="" class="col-sm-2 control-label"></label>
                <div class="col-sm-10">
                    <button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
                    <input type="hidden" name="token" value="{$_W['token']}" />
                </div>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
require(['jquery', 'util'], function($, util) {
    $(function() {
        var editor = util.editor($('#shopdesc')[0]);

    });
});
$(function() {
    $("#checkAll").click(function() {

        var checked = $(this).get(0).checked;
        var group = $(this).data('group');
        $("#regionid[data-group='" + group + "']").each(function() {
            $(this).get(0).checked = checked;
        })

    });
});
function check(form){
            if (!form['sjname'].value) {
                alert('请输入商家名称。');
                return false;
            }
            if (!form['picurl'].value) {
                alert('请上传商家图片！');
                return false;
            }
            if (!form['contactname'].value) {
                alert('请输入商家联系人。');
                return false;
            }
            if (!form['mobile'].value) {
                alert('请输入联系电话。');
                return false;
            }
            if (!form['address'].value) {
                alert('请输入商家详细地址。');
                return false;
            }
            if (!form['baidumap'].value) {
                alert('请选择商家地理坐标。');
                return false;
            }
            if (!form['shopdesc'].value) {
                alert('请输入商家简介。');
                return false;
            }
            return true;
        }
</script>
{template 'common/footer'}
